//
//  CollectionDetailViewController.m
//  Leisure
//
//  Created by xalo on 16/7/5.
//  Copyright © 2016年 Hero. All rights reserved.
//

#import "CollectionDetailViewController.h"

@interface CollectionDetailViewController ()
@property (weak, nonatomic) IBOutlet UIWebView *webview;

@end

@implementation CollectionDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.webview loadHTMLString:self.html baseURL:nil];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString *js = @"function imgAutoFit() { \
    var imgs = document.getElementsByTagName('img'); \
    for (var i = 0; i < imgs.length; ++i) {\
    var img = imgs[i];   \
    img.style.maxWidth = %f;   \
    } \
    }";
    js = [NSString stringWithFormat:js, [UIScreen mainScreen].bounds.size.width - 20];
    
    [webView stringByEvaluatingJavaScriptFromString:js];
    [webView stringByEvaluatingJavaScriptFromString:@"imgAutoFit()"];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
